package com.bjpowernode.mvc.model.param;

import com.bjpowernode.common.pay.PayUtil;
import com.bjpowernode.common.pay.Pkipair;
import lombok.Data;

/**
 * 异步通知参数
 */
@Data
public class KqNotifyParam {
    String merchantAcctId = "";
    String version = "";
    String language = "";
    String signType = "";
    String payType = "";
    String bankId = "";
    String orderId = "";
    String orderTime = "";
    String orderAmount = "";
    String bindCard = "";
    String bindMobile = "";
    String dealId = "";
    String bankDealId = "";
    String dealTime = "";
    String payAmount = "";
    String fee = "";
    String ext1 = "";
    String ext2 = "";
    String payResult = "";
    String aggregatePay = "";
    String errCode = "";
    String signMsg = "";

    //验证签名的方法
    public boolean checkSign() {
        String merchantSignMsgVal = "";
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "merchantAcctId", merchantAcctId);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "version", version);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "language", language);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "signType", signType);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "payType", payType);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "bankId", bankId);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "orderId", orderId);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "orderTime", orderTime);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "orderAmount", orderAmount);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "bindCard", bindCard);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "bindMobile", bindMobile);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "dealId", dealId);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "bankDealId", bankDealId);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "dealTime", dealTime);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "payAmount", payAmount);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "fee", fee);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "ext1", ext1);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "ext2", ext2);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "payResult", payResult);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "aggregatePay", aggregatePay);
        merchantSignMsgVal = PayUtil.appendParam(merchantSignMsgVal, "errCode", errCode);
        Pkipair pki = new Pkipair();
        boolean flag = pki.enCodeByCer(merchantSignMsgVal, signMsg);

        System.out.println("验证签名：" + flag);

        //flag = true;
        return flag;
    }
}
